/**
  ******************************************************************************
  * @file    Libraries/Device/TS32F020D/TS32F020D_LL_Driver/src/ts32f020d_ll_lvd.c
  * @author  JUSHENG Application Team
  * @version V1.0.0
  * @date    02-19-2022
  * @brief   This file contains all the LVD LL firmware functions.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 JUSHENG</center></h2>
  *
  *
  *
  ******************************************************************************
  */ 

/* Includes ------------------------------------------------------------------*/
#include "include.h"

/** @addtogroup TS32F020D_StdPeriph_Driver TS32F020D Driver
  * @{
  */
  
/** @defgroup lvd_interface_gr LVD Driver
  * @ingroup  TS32F020D_StdPeriph_Driver
  * @{
  */

/** @addtogroup LVD_LL_Driver LVD LL Driver
  * @ingroup  lvd_interface_gr
  * @{
  */
  
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/


/**
  * @}
  */

/** @defgroup LVD_LL_Data_Transfers LVD LL Data transfers functions
  * @ingroup  LVD_LL_Driver
  * @brief    LVD LL Data transfers functions 
  * @{
  */

/**
  * @brief  lvd con register set
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @param  con_bit_map : lvd con register bit map
  * @retval None
  */
void ll_lvd_con_set(LVD_TypeDef *p_lvd, u32 con_bit_map)
{
    p_lvd->LVD_CON = con_bit_map;
}

/**
  * @brief  lvd con register get
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @retval lvd con register value
  */
u32 ll_lvd_con_get(LVD_TypeDef *p_lvd)
{
    return (p_lvd->LVD_CON);
}

/**
  * @brief  use for get vdd low voltage detector enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_enable(LVD_TypeDef *p_lvd)
{
    (p_lvd)->LVD_CON |= LL_LVD_CON_VDD_LVD_EN ;
}

/**
  * @brief  use for get vdd low voltage detector disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON &= (~LL_LVD_CON_VDD_LVD_EN);
}

/**
  * @brief  use for get vcc low voltage detector enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_enable(LVD_TypeDef *p_lvd)
{
    (p_lvd)->LVD_CON |= LL_LVD_CON_VCC_LVD_EN ;
}

/**
  * @brief  use for get vcc low voltage detector disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON &= (~LL_LVD_CON_VCC_LVD_EN);
}

/**
  * @brief  use for get vdd low voltage detector debounce enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_debounce_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VDD_SHIELD_DEBOUNCE_EN));
}

/**
  * @brief  use for get vdd low voltage detector debounce disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_debounce_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VDD_SHIELD_DEBOUNCE_EN;
}

/**
  * @brief  use for get vcc low voltage detector debounce enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_debounce_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VCC_SHIELD_DEBOUNCE_EN));
}

/**
  * @brief  use for get vcc low voltage detector debounce disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_debounce_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VCC_SHIELD_DEBOUNCE_EN;
}

/**
  * @brief  enable VDD low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_reset_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VDD_RST_EN ;
}

/**
  * @brief  disable VDD low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_reset_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VDD_RST_EN));
}

/**
  * @brief  enable VCC low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_reset_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VCC_RST_EN;
}

/**
  * @brief  disable VCC low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_reset_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VCC_RST_EN));
}

/**
  * @brief  get vdd lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VDD_LVD_SET
  */
TYPE_ENUM_LL_LVD_VDD_LVD_SET ll_lvd_vdd_lvd_get(LVD_TypeDef *p_lvd)
{
    return (TYPE_ENUM_LL_LVD_VDD_LVD_SET)(((p_lvd)->LVD_CON >> 5) & 0x07);
}

/**
  * @brief  get vcc lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VCC_LVD_SET
  */
TYPE_ENUM_LL_LVD_VCC_LVD_SET ll_lvd_vcc_lvd_get(LVD_TypeDef *p_lvd)
{
    return (TYPE_ENUM_LL_LVD_VCC_LVD_SET)(((p_lvd)->LVD_CON >> 1) & 0x07);
}

/**
  * @brief  set vcc lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VCC_LVD_SET
  */
void ll_lvd_vcc_lvd_set(LVD_TypeDef *p_lvd,TYPE_ENUM_LL_LVD_VCC_LVD_SET value)
{
    p_lvd->LVD_CON &= ~(0x07 << 1);
    p_lvd->LVD_CON |= (value << 1); 
}

/**
  * @brief  set vdd lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VCC_LVD_SET
  */
void ll_lvd_vdd_lvd_set(LVD_TypeDef *p_lvd,TYPE_ENUM_LL_LVD_VDD_LVD_SET value)
{
    p_lvd->LVD_CON &= ~(0x07 << 5);
    p_lvd->LVD_CON |= (value << 5); 
}

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/*************************** (C) COPYRIGHT 2022 JUSHENG ***** END OF FILE *****/
